//
//  DateModel.m
//  ZhiHuDaily
//
//  Created by 吴宜昊 on 2022/2/6.
//

#import "DateModel.h"

@implementation DateModel

/// 日期字符串 20220206
+(instancetype) modelWithString:(NSString *) strDate {
    DateModel * model = [DateModel new];
    if (strDate.length != 8) {
        return model;
    }
    
    NSString * year = [strDate substringToIndex:4];
    
    NSString * month = [strDate substringWithRange: NSMakeRange(4, 2) ];
    
    NSString * day = [strDate substringFromIndex:6 ];
    
    model.year  = year.integerValue;
    model.month = month.integerValue;
    model.day   = day.integerValue;
    
    return model;
}

-(instancetype) init {
    self = [super init];
    if (self) {
        self.year = self.month = self.day = 0;
    }
    return self;
}

@end
